package com.xyw.code.platform.webapps.util;

import java.io.File;

/**
 * Created by xuyiwei on 2019/8/23.
 */
public class FileUtil {
    /**
     * 得到文件的后缀
     * @param file
     * @return
     */
    public static String getSuffix(File file) {
        return getSuffix(file.getName());
    }

    /**
     * 得到文件的后缀
     * @param fileName
     * @return
     */
    public static String getSuffix(String fileName) {
        int idx = fileName.lastIndexOf(".");
        idx = (idx == -1 ? fileName.length() : idx);
        return fileName.substring(idx);
    }
}
